package cn.uway.jms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;

import com.rabbitmq.client.Channel;

public class MessageListener implements ChannelAwareMessageListener {
	
	protected  Logger logger = LoggerFactory.getLogger(this.getClass());
	
	private String queueName;
	
	public MessageListener(String queueName){
		this.queueName = queueName;
	}

	@Override
	public void onMessage(Message message, Channel channel) throws Exception {
		 byte[] body = message.getBody();  
		 
         System.out.println("队列" +queueName+ "收到消息 : " + new String(body)); 
         
         channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); //确认消息成功消费  
		
	}

}
